package com.wangy.sct.serviceauth.app.rest;

import com.wangy.sct.common.core.InvokeResult;
import com.wangy.sct.serviceauth.api.UserInfo;
import com.wangy.sct.serviceauth.app.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * ClassName: AuthRest <br/>
 * Description:  <br/>
 *
 * @author wangyue
 * @version V1.0.0
 * @date 2018/11/20 7:29 PM
 */
@RestController
public class AuthRest {

	@Autowired
	private AuthService authService;

	@GetMapping(value = "/auth/{userId}", produces = MediaType.APPLICATION_JSON_VALUE)
	public InvokeResult authUserById(@PathVariable("userId") @NotNull String userId) {
		InvokeResult<UserInfo> invokeResult = new InvokeResult<>();
		UserInfo userInfo = authService.queryById(userId);
		invokeResult.setData(userInfo);
		return invokeResult;
	}

}
